package com.huafv.flyauth.web.admin.controller;


import com.huafv.flyauth.core.domain.Result;
import com.huafv.flyauth.web.admin.entity.SysDictType;
import com.huafv.flyauth.web.admin.entity.SysDictTypePage;
import com.huafv.flyauth.web.admin.service.SysDictTypeService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/dict/type")
public class SysDictTypeController extends BaseController{

    @Autowired
    private SysDictTypeService sysDictTypeService;

    // 分页查询字典类型列表
    @GetMapping()
    public Result dictTypeList(Integer pageNum,Integer pageSize){
        return sysDictTypeService.dictTypeList(pageNum,pageSize);
    }

    /*
    * 新增字典类型
    *
    * */
    @PostMapping("/add")
    public Result add(@RequestBody SysDictType sysDictType) {
        //获取当前用户名
        sysDictType.setCreateBy(getLoginName());
        return sysDictTypeService.insertDictType(sysDictType);
    }


    /*
     * 根据条件查询字典类型列表
     * */

    @PostMapping("/page")
    public Result page(@RequestBody SysDictTypePage sysDictTypePage){
        return sysDictTypeService.getByCondition(sysDictTypePage);
    }

    /*
    * 根据字典类型id删除数据,可以批量删除
    *
    * */
    @DeleteMapping("/{ids}")
    public Result remove(@PathVariable Integer[] ids){
        return sysDictTypeService.deleteDictTypeByIds(ids);
    }
}